import java.awt.Graphics;
import java.awt.Point;

public class PLLine extends PLShape{
	private static final long serialVersionUID = 1L;

	public PLLine() {
		super(ShapeIdT.kLine);
	}

	public PLLine(Point start, Point end){
		super(ShapeIdT.kLine);
		Parse(start, end);
	}
		
	// Attributes 
	public float GetLength() { return (float)Math.sqrt((mStart.x - mEnd.x)*(mStart.x - mEnd.x) + (mStart.y - mEnd.y)*(mStart.y - mEnd.y)); }
	public float GetSlope() { 
			// a negative since left top = 0,0
		if ((mStart.x - mEnd.x)==0){
			return (Float.POSITIVE_INFINITY);
		}
		else{
			return -((float)(mStart.y - mEnd.y))/(mStart.x - mEnd.x);
		}
	} 

	public float GetSlopeAngle() { 
		return (float)Math.atan(GetSlope());
	} 
	
	
	// Draw
	public void Draw(Graphics g){
		// TODO: color needs to be already set for the player 
		PLDebug.Info("Trying to draw line"); 
		// g.setColor(Color.BLACK); 
		try
		{
			g.drawLine(GetStart().x, GetStart().y, GetEnd().x, GetEnd().y); 
		}
		catch (NullPointerException e)
		{
			System.out.print("Nothing to print"); 
		}		
	}
	

	// PROTECTED
	protected void SetupLines() {	
		mLines = new PLLine[1];	

		mLines[0] = this;
		
	}
	protected void SetupCorners() {
		mCorners = new Point[2]; 

		mCorners[0] = new Point(mStart); 
		mCorners[1] = new Point(mEnd); 
		

	}	
	
}

